<template>
  <div>
    <el-dialog
      title="批量导入错误"
      :visible="open"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      width="1000px"
      append-to-body
      @close="cancel()"
    >
      <div>{{ tip }}</div>
      <el-table
        v-loading="loading"
        :height="tableHeight"
        style="margin-top: 10px"
        :data="list"
      >
        <el-table-column
          show-overflow-tooltip
          align="center"
          property="name"
          label="姓名"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          property="phoneNumber"
          label="账号(手机号)"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          property="schoolPostNames"
          label="门店-岗位"
        ></el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          property="sex"
          label="性别"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.sex == '0'">男</span>
            <span v-if="scope.row.sex == '1'">女</span>
          </template>
        </el-table-column>
        <el-table-column
          show-overflow-tooltip
          align="center"
          property="errorMsg"
          label="错误原因"
        ></el-table-column>
      </el-table>

      <div
        slot="footer"
        class="dialog-footer"
        style="display: flex; justify-content: flex-end"
      >
        <el-button v-preventReClick @click="cancel">关 闭</el-button>
        <el-button
          v-preventReClick
          icon="el-icon-download"
          type="warning"
          @click="handleTemplate"
          >下载文件</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
  
<script>
import { errorExportDown } from "@/api/schoolOrganization/student";
import { saveAs } from "file-saver";
import { tansParams, blobValidate } from "@/utils/ruoyi";
export default {
  props: {
    open: Boolean,
    list: Array,
    tip: String,
    shopId: {
      type: [String, Number],
      require: false,
    },
  },
  computed: {
    tableHeight() {
      // 在这里使用calc函数动态计算表格的高度
      return `calc(100vh - 300px)`; // 例如，计算结果为视窗高度减去200像素
    },
  },
  data() {
    return {
      loading: false,
    };
  },
  watch: {
    open(e) {},
  },
  mounted() {},
  methods: {
    async handleTemplate() {
      // let formData = new FormData();
      // formData.append("errorData", { data: this.list });
      // let data = await errorExportDown({ errorData: { data: this.list } });

      this.download(
        "/manager/account/student/errorExport",
        { errorData: JSON.stringify({ data: this.list }) },
        `errorExport_${new Date().getTime()}.xlsx`
      );
    },
    cancel() {
      this.$emit("update:open", false);
    },
  },
};
</script>
    <style scoped lang="scss">
</style>
  